package com.xiaoyu.lanling.feature.setting.activity

import android.os.Bundle
import com.xiaoyu.base.utils.extensions.setOnClickDebounceListener
import com.xiaoyu.lanling.BuildConfig
import com.xiaoyu.lanling.R
import com.xiaoyu.lanling.activity.base.AppCompatToolbarActivity
import com.xiaoyu.lanling.data.ConfigData
import com.xiaoyu.lanling.router.Router
import com.xiaoyu.lanling.router.deeplink.DeepLinkRouter
import kotlinx.android.synthetic.main.activity_about_us.*

class AboutUsActivity : AppCompatToolbarActivity() {

    override fun onCreateSafelyAfterAppFinishInit(savedInstanceState: Bundle?) {
        super.onCreateSafelyAfterAppFinishInit(savedInstanceState)
        setLightStatusBar()
        setContentView(R.layout.activity_about_us)
        initToolbar()

        initView()
        initBind()
    }

    private fun initView() {
        title = getString(R.string.about_us_title)
        version_name.text = getString(R.string.about_us_version_name_desc, BuildConfig.VERSION_NAME)
    }

    private fun initBind() {
        user_protocol_layout?.setOnClickDebounceListener {
            val url = ConfigData.getInstance().getUrl("userProtocol")
            DeepLinkRouter.getInstance().dispatch(this, url)
        }
        privacy_protocol_layout?.setOnClickDebounceListener {
            val url = ConfigData.getInstance().getUrl("privacyProtocol")
            DeepLinkRouter.getInstance().dispatch(this, url)
        }
        unregister_layout?.setOnClickDebounceListener {
            Router.instance.gotoUnregisterActivity(this)
        }
    }
}